﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfApp9
{
    public partial class TodoItemListingViewModel : ObservableObject
    {
        [ObservableProperty]
        ObservableCollection<TodoItemViewModel> _todoItemViewModels;

        public TodoItemListingViewModel()
        {
            TodoItemViewModels = new ObservableCollection<TodoItemViewModel>();
        }
        public void AddTodoItem(TodoItemViewModel item)
        {
            if (TodoItemViewModels.Contains(item))
                return;
            TodoItemViewModels.Add(item);
        }
        public void RemoveTodoItem(TodoItemViewModel item)
        {
            if (TodoItemViewModels.Contains(item))
                TodoItemViewModels.Remove(item);
        }
        [RelayCommand]
        void TodoItemDrop(object obj)
        {
            AddTodoItem(obj as TodoItemViewModel);
        }
        [RelayCommand]
        void TodoItemRemove(object obj)
        {
            RemoveTodoItem(obj as TodoItemViewModel);
        }
    }
}
